package com.zjp.controller;

import com.zjp.pojo.TypePayment;
import com.zjp.pojo.User;
import com.zjp.service.TheTypePaymentService;
import lombok.extern.slf4j.Slf4j;
import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;

/**
 * 人群类型
 */
@RestController
@Slf4j
public class TheTypePaymentController {

//    @Autowired
//    private TheTypePaymentService theTypePaymentService;

    /**
     * 类型缴费
     */
//    @PostMapping("/TheTypePayment")
//    public String updatePaymentType( @RequestParam("uploadpic") MultipartFile uploadpic, HttpSession session) throws IOException {
//        // 从session中获取当前用户信息
//        User currentUser = (User) session.getAttribute("user");
//        // 处理文件上传
//        if (!uploadpic.isEmpty()) {
//            // 获取图片上传路径
//            String paths = "D:/java软件/项目/shixunxiangmu/shixun/new_vacc/src/main/resources/static/images";
//            String originalFilename = uploadpic.getOriginalFilename();
//            File newPic = new File(paths, originalFilename);
//            uploadpic.transferTo(newPic); // 存储图片
//            currentUser.setPic(originalFilename); // 更新用户图片信息
//        }
//
//        // 更新用户信息到数据库
//        int updatedRows = theTypePaymentService.updateUserMessage(currentUser);
//        if (updatedRows > 0) {
//            return "SUCCESS";
//        }
//        return "FAIL";
//    }
}